#include <iostream>
#include <ctime>

using namespace std;

int main()
{
	//读取系统的日期时间
	time_t now = time(0);
	cout << "1970到现在经过的秒数:" << now << endl;

	//转化为字符串形式
	char *dt = ctime(&now);
	cout << "电脑时间:" << dt << endl;

	//now转tm 结构
	tm *gmtm = gmtime(&now);
	dt = asctime(gmtm);
	cout << "UTC 日期和时间:" << dt <<endl;

	tm *ltm = localtime(&now);
	cout << "年:" << 1900 + ltm->tm_year << endl;
	cout << "月:" << 1 + ltm->tm_mon << endl;
	cout << "日:" << ltm->tm_mday << endl;
	cout << "时:" << ltm->tm_hour << endl;
	cout << "分:" << ltm->tm_min << endl;
	cout << "秒:" << ltm->tm_sec << endl;

	return 0;
}
